/**
* \file NetworkContext.cpp
* \brief NetworkContext decleration class for windows plugin
* \author Edouard ROGE
* \date 12 Novembre 2013
*/

#include "TCPSocket.h"
#include "TCPServerSocket.h"
#include "UDPSocket.h"
#include "NetworkContext.h"
#include "Core/Profile/Profiler.h"
#include "Core/Profile/CodeProfile.h"
#include "Core/Thread/ThreadManager.h"

NetworkContext::NetworkContext() : m_logFile("../data/Network.log")
{
	Core::Profile::Profiler::GetInstance().SetOutputFilename("../data/Network.profile");
}

NetworkContext::~NetworkContext()
{
}

Core::Network::ITCPSocket * NetworkContext::CreateTCPSocket() const
{
	return new TCPSocket();
}

void NetworkContext::DestroyTCPSocket(Core::Network::ITCPSocket * _pSocket) const
{
	if (_pSocket)
	{
		delete (TCPSocket*)_pSocket;
	}
		
}

Core::Network::ITCPServerSocket *NetworkContext::CreateTCPServerSocket() const
{
	return new TCPServerSocket();

}

void NetworkContext::DestroyTCPServerSocket(Core::Network::ITCPServerSocket * _pSocket) const
{
	if (_pSocket)
	{
		delete (TCPServerSocket*)_pSocket;
	}
	
}

Core::Network::IUDPSocket * NetworkContext::CreateUDPSocket() const
{
	return new UDPSocket();
}

void NetworkContext::DestroyUDPSocket(Core::Network::IUDPSocket * _pSocket) const
{
	if (_pSocket)
	{
		delete (UDPSocket*)_pSocket;
	}
}
